﻿Public Class healthrelated
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btn_calculator_Click(sender As Object, e As EventArgs) Handles btn_calculator.Click
        Dim weight, height As Single
        weight = CSng(tb_weight.Text)
        height = CSng(tb_height.Text)

        
        lbl_result.Text = getBMI(tb_weight.Text, tb_height.Text)

    End Sub

    Private Function getBMI(ByVal weightStr As Single, ByVal heightStr As Single) As Single
        Dim weight, height As Single
        weight = CSng(weightStr)
        height = CSng(heightStr)

        Dim result As Single
        result = weight / (height ^ 2)
        Return CSng(result)

    End Function

    Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles tb_Height.TextChanged

    End Sub

    Protected Sub ddlbmibtn_Click(sender As Object, e As EventArgs) Handles ddlbmibtn.Click
        Response.Redirect(ddlbmi.SelectedValue)
    End Sub

    Protected Sub btnweightconverter_Click(sender As Object, e As EventArgs) Handles btnweightconverter.Click
        Dim weight As Single
        weight = CSng(tbweightconverter.Text)

        lblweightconverter.Text = (weight * 0.45359)
    End Sub

    Protected Sub btnheightconverter_Click(sender As Object, e As EventArgs) Handles btnheightconverter.Click
        Dim feet, inches As Single
        feet = CSng(tbfeetconverter.Text)
        inches = CSng(tbinchconverter.Text)


        lblheightconverter.Text = (feet * 30.48) + (inches * 2.54)

    End Sub
End Class